package com.tanhua.manager.controller;

import com.tanhua.domain.db.AnalysisByDay;
import com.tanhua.manager.service.AnalysisByDayService;
import com.tanhua.manager.service.LogService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dashboard")
public class DashboardController {
///dashboard/summary
    @Autowired
    private AnalysisByDayService analysisByDayService;

    @Autowired
    private LogService logService;

    @GetMapping(value = "/summary",name = "概要统计信息")
    public ResponseEntity summary(){
        String todayStr = DateTime.now().toString("yyyy-MM-dd");
        return   analysisByDayService.summary(todayStr);
    }

    //dashboard/users
    @GetMapping(value = "users",name = "新增、活跃用户、次日留存率")
    public ResponseEntity users(@RequestParam Long sd, @RequestParam Long ed, @RequestParam Integer type){
        return logService.users(sd,ed,type);
    }
}
